package main

import (
	"guns-go/core"
	"guns-go/global"
	"guns-go/initialize"
)

// @title Swagger Guns-Go API
// @version 0.0.1
// @description guns-go 接口文档
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @BasePath /
func main() {

	global.GVA_VP = core.Viper() // 初始化Viper
	global.GVA_LOG = core.Zap()  // 初始化zap日志库

	global.GVA_DB = initialize.Gorm() // gorm连接数据库

	initialize.Oss()   //初始化Oss
	initialize.Email() //初始化邮件配置
	initialize.Timer() //初始化定时器

	if global.GVA_DB != nil {
		initialize.MysqlTables(global.GVA_DB) // 初始化表
		// 程序结束前关闭数据库链接
		db, _ := global.GVA_DB.DB()
		defer db.Close()
	}

	core.RunWindowsServer()
}
